{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "682ef460",
   "metadata": {},
   "source": [
    "***\n",
    "* 日期：2022-09-07\\ week3（周三）\n",
    "* 课程：Python\n",
    "* 记录人：\n",
    "\n",
    "## 本周学习内容\n",
    "> 1.变量\n",
    ">> 1.变量的定义与声明\n",
    ">> 2.变量名的一般规则\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    ">2.编程的控制流\n",
    ">>1. 条件判断\n",
    "\n",
    "\n",
    ">>2. 循环遍历\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "bc61ead6",
   "metadata": {},
   "outputs": [],
   "source": [
    "##变量学习\n",
    "网三_01_ID = \"200002\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b09c1dab",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "网三_01_ID\n"
     ]
    }
   ],
   "source": [
    "print(\"网三_01_ID\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "0bf50173",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (Temp/ipykernel_14320/3501358242.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"C:\\Users\\1\\AppData\\Local\\Temp/ipykernel_14320/3501358242.py\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m    网三_01_ID=\u001b[0m\n\u001b[1;37m             ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "网三_01_ID"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "278f28fa",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "小白 网三_01_name\n"
     ]
    }
   ],
   "source": [
    "网三_01_name = \"小白\"\n",
    "\n",
    "网三_02_name =\"网三_01_name\"\n",
    "\n",
    "print(网三_01_name,网三_02_name)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d9b9b163",
   "metadata": {},
   "source": [
    "## 2.条件判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e1869f47",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 条件判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "edeaad1a",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Party!\n"
     ]
    }
   ],
   "source": [
    "#变量today需要先赋值\n",
    "today = \"Saturday\"\n",
    "\n",
    "if today ==\"Saturday\":\n",
    "    print(\"Party!\")\n",
    "elif today ==\"Sunday\":\n",
    "    if condition ==\"Headache\":\n",
    "        print(\"Recover,then rest.\")\n",
    "    else:\n",
    "        print(\"Rest\")\n",
    "else:\n",
    "    print(\"work,work,work\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "de2a1587",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=7, tm_hour=20, tm_min=6, tm_sec=56, tm_wday=2, tm_yday=250, tm_isdst=0)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "\n",
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "b8fcc1b6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "20\n",
      "37\n",
      "今天有Python课\n",
      "python课ing.现在是第三节课了\n"
     ]
    }
   ],
   "source": [
    "#创建week_day变量,time_hour变量，time_min变量\n",
    "week_day = time.localtime().tm_wday\n",
    "print(week_day)\n",
    "\n",
    "time_hour = time.localtime().tm_hour\n",
    "print(time_hour)\n",
    "\n",
    "time_min = time.localtime().tm_min\n",
    "print(time_min)\n",
    "\n",
    "if week_day ==2:\n",
    "    print(\"今天有Python课\")\n",
    "    if time_hour ==19:\n",
    "        print(\"python课ing.刚上课\")\n",
    "    elif time_hour ==18 and time_min > 44:\n",
    "              print(\"python课ing.现在在第二节课\")\n",
    "    elif time_hour ==20 and time_min < 51:\n",
    "              print(\"python课ing.现在是第三节课了\")\n",
    "    elif time_hour<18:\n",
    "            print(\"期待今天的课\")\n",
    "    else:\n",
    "            print(\"今天的Python课很不错\")\n",
    "else:\n",
    "    print(\"怎么还没到周三呢\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "423b29e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 练习题：判断今天是否有Python课 (time localtime()),然后如果今天有Python课，再判断现在是否是Python课ing\n",
    "week_day = \"time.localtime()\"\n",
    "\n",
    "if week_day ==\"time.localtime().tm_wday\":\n",
    "    print(\"Yes!\")\n",
    "    \n",
    "elif week_day ==\"time.localtime().tm_tday\":\n",
    "    print(\"No!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "284abcd7",
   "metadata": {},
   "source": [
    "## 循环遍历\n",
    "> 1.for循环\n",
    "> 2.range()方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "65c4e1b3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# 用例1 循环迭代数字变量\n",
    "for i in [1,2,3]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bc8ec0e6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 用例2\n",
    "for ch in \"Hi!\":\n",
    "    print(ch)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "75de99bb",
   "metadata": {},
   "source": [
    "### 4.1关于range"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "7f35eaf0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range可以创建数组\n",
    "# 用例3 print执行了五次（可控制次数）默认从0开始0是（start）,5是（stop）默认步长（step）1\n",
    "for num in range(5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "b51ae5a2",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "expected an indented block (Temp/ipykernel_14320/2160702767.py, line 3)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"C:\\Users\\1\\AppData\\Local\\Temp/ipykernel_14320/2160702767.py\"\u001b[1;36m, line \u001b[1;32m3\u001b[0m\n\u001b[1;33m    \u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n"
     ]
    }
   ],
   "source": [
    "# 用例3 扩展1 起点为1\n",
    "for num in range(1,5):\n",
    "    print(num)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1c057696",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# 用例3 扩展2 终点为10 步长step 2\n",
    "for num in range(21000001,21000050,2):\n",
    "    print(num)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c86e4f58",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 具体案例\n",
    "for num in range(1,12,2):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "6b3f1215",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 用例3 扩展3 \n",
    "for num in range(10,-2):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7b4acf1c",
   "metadata": {},
   "outputs": [],
   "source": [
    "#课后作业：P35项目和P43项目"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
